package com.ldy.core.service.impl;

import java.util.Date;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ldy.core.entity.BaseLogs;
import com.ldy.core.entity.BaseUser;
import com.ldy.core.mapper.BaseLogsMapper;
import com.ldy.core.service.BaseLogsService;
import com.ldy.core.util.MySession;

@Service
public class BaseLogsServiceImpl implements BaseLogsService{

	@Autowired
	private BaseLogsMapper mapper;
	
	@Override
	public Page<BaseLogs> selectPage(int current, int size,String operator, String type) {
		Page<BaseLogs> page = new  Page<BaseLogs>(current, size);
		page.setRecords(mapper.selectPageList(page,operator, type));
		return page;
	}


	@Override
	public void insert(String type, String msg) {
		BaseUser login = MySession.get();
		insert(type, msg,login.getUsername());
	}


	@Override
	@Async("taskExecutor")
	public void insert(String type, String msg, String user) {
		BaseLogs logs = new BaseLogs();
		logs.setOperationTime(new Date());
		logs.setOperator(user);
		logs.setType(type);
		logs.setMsg(msg);
		this.mapper.insert(logs);
		
	}


}
